import java.util.*;
import java.io.*;

public class UpdateByString{
    public static void main(String[] args) throws IOException{
    	FileInputStream instream = new FileInputStream("grades.txt");
    	Scanner fscanner = new Scanner(instream);

        String oldContent = "", line;

        // Read the contents of the file into the string
        while(fscanner.hasNextLine()){
        	line = fscanner.nextLine();
        	oldContent = oldContent + line +  System.lineSeparator();
        	// Note: For portability do not use:  oldContent = oldContent + line +  "\n";
        }

        //Replacing oldString with newString in the oldContent
        String newContent = oldContent.replaceAll("82.0", "95.5");
        fscanner.close();

        // Update the text-file
        FileOutputStream outstream = new FileOutputStream("Grades.txt");
        PrintWriter pwriter = new PrintWriter(outstream);
        pwriter.printf(newContent);
        pwriter.close();

        System.out.println("The file grades.txt has been updated . . .");
    }
}
